package com.ourfox.a4.commons.services;

import java.util.Collection;
import java.util.List;

import com.ourfox.a4.commons.dao.GenericDao;
import com.ourfox.a4.commons.exception.PortalException;

/**
 * 
 * @Description: 默认的service层的基本操作接口
 * @author xiujin.luo@gmail.com
 * @date 2013-4-11 上午2:08:32 
 * @version V1.0.0
 * @param <PO>
 * @param <ID>
 * @param <DAO>
 */
public interface GenericService<PO, ID, DAO extends GenericDao<PO, ID>> {

	/**
	 * 
	 * @Description: 添加数据
	 * @param po
	 * @throws PortalException    
	 * @return int     
	 */
	public int add(PO po) throws PortalException;

	/**
	 * 
	 * @Description: 批量添加
	 * @param poList
	 * @throws PortalException    
	 * @return int     
	 */
	public int add(Collection<PO> poList) throws PortalException;

	/**
	 * 
	 * @Description: 修改数据
	 * @param po
	 * @throws PortalException    
	 * @return void     
	 */
	public void update(PO po) throws PortalException;

	/**
	 * 
	 * @Description: 批量修改
	 * @param poList
	 * @throws PortalException    
	 * @return void     
	 */
	public void update(Collection<PO> poList) throws PortalException;

	/**
	 * 
	 * @Description: 跟据主健删除数据
	 * @param id
	 * @throws PortalException    
	 * @return void     
	 */
	public void removeById(ID id) throws PortalException;

	/**
	 * 
	 * @Description: 跟据条件删除数据
	 * @param po 条件
	 * @throws PortalException    
	 * @return void     
	 */
	public void remove(PO po) throws PortalException;

	/**
	 * 
	 * @Description: 跟据主健值批量删除数据
	 * @param idList
	 * @throws PortalException    
	 * @return void     
	 */
	public void remove(Collection<ID> idList) throws PortalException;

	/**
	 * 
	 * @Description: 跟据主健ID获取数据
	 * @param id
	 * @throws PortalException    
	 * @return PO     
	 */
	public PO get(ID id) throws PortalException;

	/**
	 * 
	 * @Description: 分页查询数据
	 * @param po 查询条件
	 * @param startRow 开始值
	 * @param rowCount 每页显示条数
	 * @throws PortalException    
	 * @return List<PO>     
	 */
	public List<PO> query(PO po, int startRow, int rowCount)
			throws PortalException;

	/**
	 * 
	 * @Description: 查询总数
	 * @param po 条件
	 * @throws PortalException    
	 * @return int     
	 */
	public int getCount(PO po) throws PortalException;
	/**
	 * 
	 * @Description: service对应的DAO
	 * @return DAO     
	 */
	public abstract DAO getDAO();
}
